package com.xiaozhichao.javaapi.designpattern.factory;


import com.xiaozhichao.javaapi.designpattern.factory.abstracttype.MailFactory;
import com.xiaozhichao.javaapi.designpattern.factory.abstracttype.Provider;
import com.xiaozhichao.javaapi.designpattern.factory.abstracttype.SmsFactory;
import com.xiaozhichao.javaapi.designpattern.factory.general.GeneralFactory;
import com.xiaozhichao.javaapi.designpattern.factory.multiple.MultipleFactory;
import com.xiaozhichao.javaapi.designpattern.factory.statictype.StaticFactory;
import org.junit.Test;

public class FactoryTest {

    @Test
    public void testGeneral(){
        GeneralFactory factory = new GeneralFactory();
        Sender sender1 = factory.produce("sms");
        Sender sender2 = factory.produce("mail");
        sender1.send();
        sender2.send();

    }

    @Test
    public void testMultiple(){
        MultipleFactory factory = new MultipleFactory();
        Sender sender1 = factory.smsProduce();
        Sender sender2 = factory.mailProduce();
        sender1.send();
        sender2.send();

    }

    @Test
    public void testStatic(){
        Sender sender1 = StaticFactory.smsProduce();
        Sender sender2 = StaticFactory.mailProduce();
        sender1.send();
        sender2.send();

    }

    @Test
    public void testAbstract(){
        Provider provider1 = new SmsFactory();
        Provider provider2 = new MailFactory();
        Sender sender1 = provider1.produce();
        Sender sender2 = provider2.produce();
        sender1.send();
        sender2.send();

    }
}
